﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;
using System.Drawing;

namespace Noris.Tools.TraceVisualiser.Forms
{
    internal class GetTextDialogForm : Noris.Tools.TraceVisualiser.Components.DForm
	{
		public GetTextDialogForm()
		{
			InitializeComponent();
            this.Init();
            this.AdjustSize();
		}
        protected void Init()
        {
            // Tyto property nemá význam nastavovat v designeru, protože se z kompomnenty OkStornopanel mají přenést do Formu, ale z hlediska pořadí v InitializeComponent() to nejde.
            // Proto je nastavuji zde:
            this._OkStorno.AcceptFormEnable = true;
            this._OkStorno.CancelFormEnable = true;
        }
        protected void AdjustSize()
        {
            Point lastPoint = Point.Empty;
            foreach (Control c in this.Controls)
            {
                if (c.Right > lastPoint.X) lastPoint.X = c.Right;
                if (c.Bottom > lastPoint.Y) lastPoint.Y = c.Bottom;
            }
            // Margin:
            lastPoint.X += 6;
            lastPoint.Y += 6;
            if (this.ClientSize.Width > lastPoint.X)
                lastPoint.X = this.ClientSize.Width;
            if (this.ClientSize.Height > lastPoint.Y)
                lastPoint.Y = this.ClientSize.Height;
             
            this.ClientSize = new Size(lastPoint);
        }

		private Label _Label;
		private TextBox _Text;
        private Noris.Tools.TraceVisualiser.Components.OkStornoPanel _OkStorno;

		#region Windows Form Designer generated code

		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.IContainer components = null;

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
		protected override void Dispose(bool disposing)
		{
			if (disposing && (components != null))
			{
				components.Dispose();
			}
			base.Dispose(disposing);
		}

		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            this._Label = new System.Windows.Forms.Label();
            this._Text = new System.Windows.Forms.TextBox();
            this._OkStorno = new Noris.Tools.TraceVisualiser.Components.OkStornoPanel();
            this.SuspendLayout();
            // 
            // _Label
            // 
            this._Label.AutoSize = true;
            this._Label.Location = new System.Drawing.Point(18, 9);
            this._Label.Name = "_Label";
            this._Label.Size = new System.Drawing.Size(25, 13);
            this._Label.TabIndex = 0;
            this._Label.Text = "Info";
            // 
            // _Text
            // 
            this._Text.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this._Text.Location = new System.Drawing.Point(15, 24);
            this._Text.Name = "_Text";
            this._Text.Size = new System.Drawing.Size(287, 20);
            this._Text.TabIndex = 1;
            // 
            // _OkStorno
            // 
            this._OkStorno.AcceptFormEnable = true;
            this._OkStorno.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this._OkStorno.CancelFormEnable = true;
            this._OkStorno.Location = new System.Drawing.Point(139, 49);
            this._OkStorno.Name = "_OkStorno";
            this._OkStorno.Size = new System.Drawing.Size(163, 29);
            this._OkStorno.Spacing = 2;
            this._OkStorno.TabIndex = 2;
            this._OkStorno.ToolTipTitle = "";
            this._OkStorno.OkClick += new System.EventHandler(this._OkStorno_OkClick);
            this._OkStorno.StornoClick += new System.EventHandler(this._OkStorno_StornoClick);
            // 
            // GetTextDialogForm
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(314, 81);
            this.Controls.Add(this._OkStorno);
            this.Controls.Add(this._Text);
            this.Controls.Add(this._Label);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
            this.MaximumSize = new System.Drawing.Size(2394, 115);
            this.MinimumSize = new System.Drawing.Size(250, 115);
            this.Name = "GetTextDialogForm";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
            this.Text = "Zadejte text";
            this.ResumeLayout(false);
            this.PerformLayout();

		}
		#endregion
		#region Interní eventy
		private void _OkStorno_OkClick(object sender, EventArgs e)
		{
			this.DialogResult = System.Windows.Forms.DialogResult.OK;
			this.Close();
		}

		private void _OkStorno_StornoClick(object sender, EventArgs e)
		{
			this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.Close();
		}
		#endregion
		#region Property
		/// <summary>
		/// Text v labelu = popisek vstupního údaje
		/// </summary>
		[Browsable(false)]
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public string LabelText
		{
			get { return this._Label.Text; }
			set { this._Label.Text = value; }
		}
		/// <summary>
		/// Text v labelu = popisek vstupního údaje
		/// </summary>
		[Browsable(false)]
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public string TextboxText
		{
			get { return this._Text.Text; }
			set { this._Text.Text = value; }
		}
		#endregion
	}
}
